package com.yuki.provider.component;

import com.yuki.api.service.IOmsOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: Yuki Tadayoshi
 * @time: 2021/4/1 16:16
 */
@Component
@RabbitListener(queues = "mall.order.cancel")
public class CancelOrderReceiver {
    private static Logger LOGGER = LoggerFactory.getLogger(CancelOrderReceiver.class);

    @Autowired
    private IOmsOrderService omsOrderService;

    @RabbitHandler
    public void handler(Long orderId) {
        omsOrderService.cancelOrder(orderId);
        LOGGER.info("cancel orderId:{}", orderId);
    }
}
